package com.koma.mvpdemo.presenter;

import com.koma.mvpdemo.view.IMainView;

/**
 * Created by chengengsen on 2016/9/30.
 */
public class MainPresenter {

    private static final String TAG = "MainActivity";

    private IMainView view;

    public MainPresenter(IMainView view){
        this.view = view;
    }

    //处理登录逻辑
    public void login(String username, String password){

        if(username.isEmpty() || password.isEmpty()){
            view.LoginFailed("账号和密码不能为空");
        }else if(password.length() < 6 || password.length() > 20){
            view.LoginFailed("密码须在6-20位之间");
        }else{
            if(username.equals("admin")){
                if(password.equals("123456")){
                    view.LoginSuccess();
                }else{
                    view.LoginFailed("密码错误");
                }
            }else{
                view.LoginFailed("用户名错误");
            }
        }
    }


}
